// Copyright 2018 Palantir Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0.

@use "sass:list";
@use "sass:map";

$pkg-icon-width: $pt-spacing * 6;

$package-colors: (
  "blueprint": (
    $gray1,
    $black,
  ),
  "core": (
    $blue3,
    $blue2,
  ),
  "datetime": (
    $red3,
    $red2,
  ),
  "datetime2": (
    $rose3,
    $rose2,
  ),
  "icons": (
    $gold4,
    $gold3,
  ),
  "select": (
    $cerulean3,
    $cerulean2,
  ),
  "table": (
    $forest3,
    $forest2,
  ),
  "labs": (
    $indigo3,
    $indigo2,
  ),
);

$dark-package-colors: (
  "blueprint": (
    $gray3,
    $white,
  ),
  "core": (
    $blue4,
    $blue5,
  ),
  "datetime": (
    $red4,
    $red5,
  ),
  "datetime2": (
    $rose4,
    $rose5,
  ),
  "icons": (
    $gold4,
    $gold5,
  ),
  "select": (
    $cerulean4,
    $cerulean5,
  ),
  "table": (
    $forest4,
    $forest5,
  ),
  "labs": (
    $indigo4,
    $indigo5,
  ),
);

.docs-logo {
  display: block;
  margin-right: $sidebar-padding;
  opacity: 0.8;
  transition: opacity ($pt-transition-duration * 2) $pt-transition-ease;

  &:hover {
    opacity: 0.9;
  }

  &:active {
    opacity: 1;
  }

  svg {
    fill: $dark-gray5;

    .#{$ns}-dark & {
      fill: $gray5;
    }
  }
}

.docs-heading {
  font-size: $pt-spacing * 5;
  font-weight: 600;
  margin-right: $pt-spacing * 2;

  .#{$ns}-tag {
    margin-left: $pt-spacing;
    padding-left: $pt-spacing * 2;
    vertical-align: middle;
  }
}

.docs-version-list {
  max-height: $pt-spacing * 50;
  min-width: $pt-spacing * 30;
  overflow: auto;
}

.docs-nav-tag {
  padding-bottom: 0;
  padding-top: 0;
}

.docs-nav-package-icon {
  border-radius: $pt-border-radius * 3;
  margin-right: $pt-spacing * 2;
}

.docs-nav-package {
  @include pt-flex-container(row);
  align-items: center;

  .#{$ns}-menu-item {
    background-color: transparent;
    flex: 1 1 auto;
    font-weight: 600;
    text-transform: uppercase;
  }

  @each $package-name in map.keys($package-colors) {
    $color: list.nth(map.get($package-colors, $package-name), 1);
    $dark-color: list.nth(map.get($dark-package-colors, $package-name), 1);
    $text-color: list.nth(map.get($package-colors, $package-name), 2);
    $dark-text-color: list.nth(map.get($dark-package-colors, $package-name), 2);

    &[data-route="#{$package-name}"] {
      .docs-nav-package-icon {
        background-color: rgba($color, 0.1);
        fill: $color;

        .#{$ns}-dark & {
          background-color: rgba($dark-color, 0.15);
          fill: $dark-color;
        }
      }

      /* stylelint-disable max-nesting-depth */
      &:hover,
      &.docs-nav-expanded {
        .#{$ns}-menu-item,
        + .docs-nav-menu .#{$ns}-menu-item.#{$ns}-active {
          color: $text-color;

          .#{$ns}-dark & {
            color: $dark-text-color;
          }
        }

        .docs-nav-package-icon {
          background-color: rgba($color, 0.8);
          fill: $white;

          .#{$ns}-dark & {
            background-color: rgba($dark-color, 0.8);
          }
        }

        &:active .docs-nav-package-icon {
          background-color: $color;

          .#{$ns}-dark & {
            background-color: $dark-color;
          }
        }
      }
      /* stylelint-enable max-nesting-depth */
    }
  }

  + .docs-nav-menu {
    margin-bottom: $pt-spacing;
    margin-left: $pkg-icon-width + ($pt-spacing * 2);

    &:empty {
      display: none;
    }
  }
}

.docs-nav-section {
  font-size: small;
  font-weight: 700;
  margin-bottom: $pt-spacing * 2;
  margin-top: $pt-spacing * 5;
  text-transform: uppercase;

  // dedent menu under a section title
  + .docs-nav-menu {
    margin-left: 0;
  }
}

.docs-copyright {
  align-items: center;
  display: flex;

  svg {
    height: 1.2em;
    padding: 0 $pt-spacing;
  }

  a:not(:hover) {
    color: inherit;
  }
}
